package cn.com.oyat.idea.controller.virtual;

import cn.com.oyat.idea.service.SsdpDiscoveryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ControlController {

    @Autowired
    private SsdpDiscoveryService ssdpService;

    /**
     * 手动发送设备发现通知
     */
    @PostMapping("/api/broadcast")
    public String broadcastPresence() {
        try {
            ssdpService.sendAliveNotification();
            return "✅ 已发送设备广播通知";
        } catch (Exception e) {
            return "❌ 发送广播失败: " + e.getMessage();
        }
    }

    /**
     * 获取设备状态
     */
    @PostMapping("/api/status")
    public String getStatus() {
        return "🟢 设备运行中 - " + ssdpService.getDeviceInfo();
    }
}